<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="/css/common.css" rel="stylesheet" type="text/css" />
<style>
.wrapContent {height:600px;margin:0 auto;padding:0 30px;}
.center {text-align:center;}
.block {padding:10px 30px;}
.topBorder {border-top:1px solid #000;}
.rightBorder {border-right:1px solid #000;}
.lineHeight{height:26px;line-height:26px;}
.addLine {float:right;margin:0 20px 5px 0;}
</style>
</head>
<body>
<div class="wrapContent">
	<div class="block">
		<h2 class="center">机器管理</h2>
		<?php
			if (empty($machineList['data'])){
				echo '<div class="center" style="margin:50px 0 0 0">还没有机器，马上<a href="/admin/machine.php?op=add">添加机器</a></div>';
			}else{
		?>
		<p class="addLine"><a href="/admin/machine.php?op=add">添加机器</a></p>
		<table cellpadding="0" cellspacing="0" style="width:100%;border:1px solid #000">
			<thead class="lineHeight">
				<td width="20%" class="rightBorder center">机器名称</td>
				<td width="50%" class="rightBorder center">硒鼓型号</td>
				<td width="30%" class="center">操作</td>
			</thead>
			<?php
			foreach($machineList['data'] as $machine){
				$machineName = $machine['name'];
				echo '<tr class="lineHeight">';
				echo '<td class="topBorder rightBorder center">'.$machineName.'</td>';
				echo '<td class="topBorder rightBorder center">'.$machineInfos['data'][$machineName].'</td>';
				echo '<td class="topBorder center"><a href="/admin/machine.php?op=modify&id='.$machine['id'].'">修改信息</a> <a href="#" onclick="delById('.$machine['id'].');">删除</a></td>';
				echo '</tr>';	
			}
			?>
		</table>
		<?php echo '<p class="page">' . ObjectFinder::get('PageUtil')->pagination($machineList['total'], $conf['pageSize'], $page, $conf['baseUrl'].'/admin/machine.php?op=manage', 100) . '</p>'; ?>
		<?php } ?>
	</div>
</div>
<script src="/js/lib.min.js" type="text/javascript"></script>
<script type="text/javascript">
function delById(id){
	if (confirm('确定要删除该机器？')) {
		$.ajax({
			url:'/admin/machine.php?op=doDelete',
			data:{'id': id},
			type:'POST',
			callback:function(res){
				if (res.errno == 0){
					alert(res.errmsg);
					location.reload();
				}else{
					alert(res.errmsg);
				}
			}
		});
	}
}
</script>
</body>
</html>